package cn.itcast.product.controller;

import cn.itcast.entity.Product;
import cn.itcast.product.service.ProductService;
import com.sun.org.apache.bcel.internal.generic.RETURN;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/product")
@RefreshScope
public class ProductController {

	@Autowired
	private ProductService productService;

	@GetMapping
	public List findAll() {
		return productService.findAll();
	}

	@Value("${server.port}")
	private String port;

	@Value("${spring.cloud.client.ip-address}")
	private String ip;

	@GetMapping("/{id}")
	public Product findById(@PathVariable Long id) {
		return productService.findById(id);
	}

	@Value("${productValue}")
	private String productValue;

	@GetMapping("/test")
	public String findById() {
		return productValue;
	}

}
